def isPrime(num):
    for i in range(2, num // 2 + 1):
        if num % i == 0:
            return False
    return True
def reverse(num):
    reversedNum = 0
    while num != 0:
        reversedNum = reversedNum * 10 + num % 10
        num //= 10
    return reversedNum
def isPalindrome(num):
    reversedNum = reverse(num)
    return num == reversedNum

count = 0
num = 2
while True:
    if isPrime(num) and isPalindrome(num):
        print(num, end=" ")
        count += 1
        if count % 10 == 0:
            print()
        if count == 100:
            break
    num += 1
